/**
 * 用于完成对Ajax的通用封装
 * @param url
 * @param method
 * @param data
 * @param callback
 * @returns
 */
function myAjax(url, method, data, callback) {
    let contentType = "application/json";
    let options = {url: url, type: method, contentType: contentType};
    if (data != null) options.data = JSON.stringify(data);
    $.ajax(options)
        .done(function (obj) {
            callback(obj);
        })
}

/**
 * 用于将form中的域转换为JSON
 * @param form
 * @returns
 */
function form2json(form) {
    let obj = {};
    $.each(form.children("[type!=submit]"), (index, item) => {
        let $item = $(item);
        obj[$item.attr("name")] = $item.val();

    })
    return obj;
}